<?php
defined('_JEXEC') or die('Restricted access');
// получаем содержимое корзины из cookie 
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__shop_onmain ORDER BY ordering ASC";
$db->setQuery($query);
$onmain = $db->loadObjectList();
$ids = array();
foreach($onmain as $temp){
	$ids[] = $temp->prod_id;
}
$ids = implode(',',$ids);
?>
	<table class="main_table" style="position:relative;float:left;" cellpadding=0 cellspacing=0>
		<tr >
	<?php
	$i = 0;
	if($ids != ''){
	$query = "SELECT id,main_img,articul,name,price,old_price FROM #__shop_prod WHERE id IN (".$ids.")";
	$db->setQuery($query);
	$goods = $db->loadObjectList();
	$new_goods =array();
	foreach($onmain as $temp){
	
			foreach($goods as $key=>$good){
			if($temp->prod_id == $good->id){
				$new_goods[] = $good;
				unset($goods[$key]);
				break;
			}
		}
	}
foreach($new_goods as $good){	
	if($good->main_img != '' && $good->articul != ''){
		$size = getimagesize ('components/com_shop/images/main_page/'.$good->main_img);
		?>
				
					<td class="frame_center_left">
					
					</td>
					<td class="frame_center" align="center" style="" valign="top">
					<div style="width:<?php echo $size[0]?>px;<?php echo $size[1];?>:240px;"> 
						<div class="image_div">
							<div class="corner_left_top"></div>
							<div class="corner_right_top"></div>
							<div class="corner_right_bottom"></div>
							<div class="corner_left_bottom"></div>
							<a href="index.php?option=com_shop&view=item&id=<?php echo $good->articul;?>" style="font-size: 0px;">
								<img   src="components/com_shop/images/main_page/<?php echo $good->main_img;?>" alt="<?php echo $good->name?>"/>
							</a>
						</div>
						
					</div>
					<div class="title_div"><a href="index.php?option=com_shop&view=item&id=<?php echo $good->articul;?>"><?php echo htmlspecialchars($good->name);?></a></div>
						
						Цена:<span style="color:#7e0101;"><?php echo $good->price;?>.00 РУБ</span><br/>
						<?php if($good->old_price != 0){ ?>Старая цена: <span style="text-decoration:line-through;color:#7e0101;"><?php echo $good->old_price.'.00 руб.';?></span><br/><?php }?>
					</td>
					<td class="frame_cente_right" rowspan=2 valign=bottom>
						<div class="bottom_frame_right"></div>
					</td>
					
				
			
		<?php
		$i++;
		if($i%3 == 0) echo '</tr><tr>
					<td colspan=2 class="bottom_frame">
						<div class="frame_left">
						</div>
						
						<div class="frame_right">
						</div>
					</td>
					<td colspan=2 class="bottom_frame">
						<div class="frame_left">
						</div>
						
						<div class="frame_right">
						</div>
					</td>
					<td colspan=2 class="bottom_frame">
						<div class="frame_left">
						</div>
						
						<div class="frame_right">
						</div>
					</td>
				</tr><tr >';
	}
	
}
	if($i%3 != 0){
		echo '</tr><tr>';
		for($j=0;$j<$i%3;$j++)
			echo 	'<td colspan=2 class="bottom_frame">
						<div class="frame_left">
						</div>
						
						<div class="frame_right">
						</div>
					</td>
					';
		echo '</tr>';	
	}
}	
?>
		
	</table>
